package com.example.tool.activtiy;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.example.tool.R;
import com.example.tool.activtiy.base.BaseActivity;
import com.example.tool.activtiy.recylerview.AdapterActivtiy;
import com.example.tool.adapter.HomeRvAdapter;
import com.example.tool.listener.OnItemListener;
import com.example.tool.mvp.CommonPresent;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity<CommonPresent> {
    RecyclerView recyclerView;
    private LinearLayoutManager layoutManager;
    private HomeRvAdapter homeRvAdapter; //测试合并
    private String[] strings = null;
    private TextView tvTitle; //wqeqfeef

    @Override
    protected int getLayoutId() {
        return R.layout.activity_main;
    }

    @Override
    protected void initView() {
        strings = getResources().getStringArray(R.array.ui_array);
        recyclerView = findViewById(R.id.rv_home);
        tvTitle = findViewById(R.id.tv_title);
        layoutManager = new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false);
        recyclerView.setLayoutManager(layoutManager);
        homeRvAdapter = new HomeRvAdapter(getData());
        tvTitle.setText("UI工具类");
    }

    @Override
    protected void initData() {
        getData();
        recyclerView.setAdapter(homeRvAdapter);
    }

    @Override
    protected void initEvent() {

        homeRvAdapter.setOnItemListener(new OnItemListener() {
            @Override
            public void OnItemClick(int postion) {
                switch (postion) {
                    case 0:
                        startToActivity(MainActivity.this, FoldActivity.class);
                        break;

                    case 1:
                        startToActivity(MainActivity.this, AdapterActivtiy.class);
                        break;
                    case 2:
                        startToActivity(MainActivity.this, PopStyleActivity.class);
                        break;
                    case 3:
                        startToActivity(MainActivity.this, NotificationActivity.class);
                        break;
                    case 4:
                        startToActivity(MainActivity.this, PopWindownActivity.class);
                        break;
                    case 5:
                        startToActivity(MainActivity.this, AnimActivity.class);
                        break;
                    case 6:
                        startToActivity(MainActivity.this, CopyKeepActivity.class);
                        break;
                    case 7:
                        startToActivity(MainActivity.this, CustomViewActivity.class);
                        break;
                    case 8:
                        startToActivity(MainActivity.this, FontActivity.class);
                        break;
                    case 9:
                        startToActivity(MainActivity.this, ScanActivity.class);
                        break;
                    case 10:
                        startToActivity(MainActivity.this, FlexboxLayoutActivity.class);
                        break;
                    case 11:
                        startToActivity(MainActivity.this, InflateActivity.class);
                        break;
                    case 12:
//                        startToActivity(MainActivity.this, CalendarTimeAxleActivity.class);
                        startToActivity(MainActivity.this, TimeAxleActivity.class);

                }
            }
        });
    }

    @Override
    protected CommonPresent createPresenter() {
        return null;
    }

    @Override
    protected void onResume() {
        super.onResume();

    }

    private List<String> getData() {
        List<String> list = new ArrayList<>();
        for (int i = 0; i < strings.length; i++) {
            list.add(strings[i]);
        }
        return list;
    }
}
